class ClassName { Data members ------------ Member functions ------------ };
[AccessSpecifier] [Modifier] returntype funcName(datatype arg1,...) { Statements --------- return value; }
class Rectangle { int length; int breadth; void area() { int a=length*breadth; System.out.println("Area is "+a); } void perimeter() { int p=2*(length+breadth); System.out.println("Perimeter is"+p); } }
class box { int L,B,H; void volume() { int v=L*B*H; System.out.println("Volume is"+v); } }
class Circle { int R; void area() { double a=3.14*R*R; System.out.println("Area is "+a); } void circuimference() { double c=2*3.14*R; System.out.println("Circumference is"+c); } }
class Set { int n1,n2,n3; void sum() { int s=n1+n2+n3; System.out.println("Sum is "+s); } void mean() { double m =(n1+n2+n3)/3.0; System.out.println("mean is "+m); } }
class MarkSheet { int eng,hin,mar,mat,sci; void total() { int t=eng+hin+mar+mat+sci; System.out.println("Total is "+t); } void percentage() { int t=eng+hin+mar+mat+sci; double p=t*100/500.0; System.out.println("Percentage is"+p); } void result() { if(eng>=40&&hin>=40&&mar>=40&& mat>=40&&sci>=40) System.out.println("pass"); else System.out.println("fail"); } }